import {dicUrl, khglUrl} from '@/config/env'
import request from '@/router/request'
import {menuAll} from '@/mock/menu'

export const loginByUsername = (username, password, code, randomStr) => {
  const grant_type = 'password';
  const scope = 'server';
  return request({
    url: '/auth/oauth/token',
    headers: {
      'Authorization': 'Basic cGlnOnBpZw=='
    },
    method: 'post',
    params: {username, password, randomStr, code, grant_type, scope}
  })
}

export function mobileLogin(mobile, code) {
  const grant_type = 'mobile';
  const scope = 'server';
  return request({
    url: '/auth/mobile/token',
    headers: {
      'Authorization': 'Basic cGlnOnBpZw=='
    },
    method: 'post',
    params: {mobile, code, grant_type, scope}
  })
}

export const getUserInfo = () => {
  return request({
    url: '/upms/user/info',
    method: 'get'
  })
}

export const logout = (accessToken, refreshToken) => {
  return request({
    url: '/auth/oauth/token',
    method: 'delete',
    params: {accessToken, refreshToken}
  })
}
